import requests

bot_url = 'http://127.0.0.1:8000'

get_url = bot_url + '/commodity'

proxies = {
    'http':'http://127.0.0.1:8888'
}
session = requests.session()

login_url = bot_url + '/login'
login_data = {
    'username':'admin',
    'password':'123456'
}
res = session.post(login_url,data=login_data)
session.headers['Authorization'] = 'JWT ' + res.json()['token']

res = session.get(get_url,proxies=proxies)
print(res.json())
print(res.status_code)



commod_url = bot_url + '/commodity'
fortify_data = {
    'name':'iu',
    'price':'100'
 }

res = session.post(commod_url,data=fortify_data,proxies=proxies)
print(res.json())
print(res.status_code)


put_data ={
    'name':'iu',
    'price':'99'
}
res = session.put(commod_url+'/8',data=put_data,proxies=proxies)
# print(res.json())
# print(res.status_code)

patch_data ={
    'name':'iu',
    'price':'99'
}
res = session.patch(commod_url+'/4',data=patch_data,proxies=proxies)



res = session.delete(commod_url+'/8',proxies=proxies)
print(res.json())
print(res.status_code)